import request from '@/utils/request'

/**
 * 拉取私聊离线消息
 * @param {string} maxMessageId
 * @param {object} option
 * @returns {*}
 */
export const getPrivateOfflineMessage = (maxMessageId, option) => {
  return request.get('/store/im/privates/offline-messages/pull', { maxMessageId }, option)
}

/**
 * 撤回私聊消息
 * @param messageId
 * @param option
 * @returns {*}
 */
export const recallPrivateMessage = (messageId, option) => {
  return request.post(`/store/im/privates/messages/${messageId}/recall`, {}, option)
}

/**
 * 发送私聊消息
 * @param data
 * @param option
 * @returns {*}
 */
export const sendPrivateMessage = (data, option) => {
  return request.post('/store/im/privates/messages/send', data, option)
}

/**
 * 私聊消息已读
 * @param friendId
 * @param option
 * @returns {*}
 */
export const readPrivateMessage = (friendId, option) => {
  return request.post('/store/im/privates/messages/read', { senderId: friendId }, option)
}

/**
 * 分页查询私聊历史消息
 * @param {object} params
 * @param {object} option
 * @returns {*}
 */
export const getPrivateHistoryMessage = (params, option) => {
  return request.get('/store/im/privates/history-messages/page', params, option)
}

/**
 * 保存常用语配置
 * @param shopId
 * @param config
 * @returns {*}
 */
export const saveQuickReplyConfig = (shopId, config) => {
  return request.post('/store/settings/im/shops/common-phrases-config/save', { shopId, config }, {})
}

/**
 * 获取常用语配置
 * @param shopId
 * @returns {*}
 */
export const getQuickConfig = (shopId) => {
  return request.get(`/store/settings/im/shops/${shopId}/common-phrases-config`, {}, { load: false, isPrompt: false })
}
